{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">站点管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <blockquote class="layui-elem-quote">添加、修改和删除站点全部完成后，请点击【更新站点缓存】！</blockquote>
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
        </div>
    </div>
</div>
<script type="text/html" id="logo">
    {{# if(d.logo ==0){ }}无
    {{#  } else { }}
    <div>有图</div>
    {{#  } }}
</script>
<script type="text/html" id="icon">
    {{# if(d.mark ==0){ }}无
    {{#  } else { }}
    <div><img src="/static/language/{{d.mark}}.png" alt=""></div>
    {{#  } }}
</script>

<script type="text/html" id="url">
    <div><a href="{{ d.http }}://{{ d.domain }}" target="_blank"><i class="iconfont icon-lianjie"></i> {{ d.http }}://{{ d.domain }}</a></div>
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" value="{{d.id}}" data-href="{:url('multi')}?id={{d.id}}&param=status" lay-skin="switch" lay-text="开启|关闭" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="barTool">
    {{# if(d.sites !=1){ }}
    <a data-open="{{d.add_url}}" data-width="900px" data-height="600px" class="layui-btn layui-btn-xs layui-btn-normal" title="添加子栏目">添加子站点</a>
    {{#  } }}
    {{#  if(d.sites !=1 || d.id == 1){ }}
    <a data-open='{:url("edit")}?id={{ d.id }}' data-width="900px" data-height="600px" class="layui-btn layui-btn-xs" title="编辑">编辑</a>
    {{#  } else { }}
    <a data-width="900px" data-height="600px" class="layui-btn layui-btn-xs layui-btn-disabled" title="编辑">编辑</a>
    {{#  } }}
    <a href='{:url("del")}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
</script>

{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        delete_url: "{:url('del')}",
        modify_url: '{:url("multi")}',
    };

    table.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        toolbar: ['refresh',
            [{
                    text: '新增站点',
                    url: "{:url('add')}",
                    method: 'open',
                    class: 'layui-btn layui-btn-sm layui-btn-normal',
                    icon: 'iconfont icon-add',
                    extend: 'data-width="900px" data-height="600px"',
                }
            ], 'delete', [
                {
                text: "更新站点缓存",
                url: "{:url('site_cache')}",
                method: 'request',
                class: 'layui-btn layui-btn-sm',
                icon:'iconfont icon-shuaxin1',
                extend: 'data-table="currentTable"',
            }]
        ],
        url: '{:url("index")}',
        search:false,
        cols: [
            [
                {field: 'id', title: 'ID', width: 80, fixed: true, sort: true,align:"center"},
                { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
                {field: 'name', title: '站点名称', width: 300,align:"center"},
                {field: 'mark', title: '站点标识', width: 120,align:"center" },
                {field: 'template', title: '主题风格', width: 120,align:"center" },
                {field: 'icon', title: '站点语言', width: 100,templet:"#icon",align:"center",search:false },
                { field: 'domain', title: 'URL',templet:'#url'},
                { field: 'logo', width: 100, title: 'LOGO', search: false, templet: yznTable.image, align:"center" },
                { field: 'favicon', width: 100, title: '站点图标', search: false, templet: yznTable.image, align:"center"},
                { field: 'status', width: 120, align: "center", title: '状态', templet: '#statusTpl', unresize: true,search:false },
                {fixed: 'right', title:'操作',width:250, toolbar: '#barTool',align:"center"},
            ]
        ],
    });
});
</script>
{/block}